package testString;

import java.util.Random;
import java.util.Scanner;

public class Password {
    public static void main1(String[] args) {
        String[] ss = {"a","b","c","s","z","1","2","3","0","A","Z","F"};
        Random rd = new Random();
        String myCode = "";
        for(int i = 1; i <= 4; i++)
        {
            int index = rd.nextInt(ss.length);
            String s = ss[index];
            myCode += s;
        }
        System.out.println(myCode);

        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入验证码:>");
            String password = sc.next();
            if(password.length() < 4){
                System.out.println("长度不够!");
            }else if(myCode.equalsIgnoreCase(password)){
                System.out.println("验证成功!");
                break;
            }else{
                System.out.println("验证码有误!");
            }
        }

    }

    public static void main2(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名:>");
        String name = sc.next();

        if(name.indexOf("教") == 0){
            System.out.println("我是教一组");
        }else{
            System.out.println("我不是");
        }
    }

    public static void main(String[] args) {
        String str1 = "hello world";
        System.out.println(str1.toUpperCase());
        System.out.println(str1.toLowerCase());
        System.out.println("------------------");

        String str2 = "TestDemo.java";
        System.out.println(str2.endsWith(".java"));
        System.out.println(str2.startsWith("Test"));
        System.out.println("------------------");

        String str3 = " Hell 0 World";
        System.out.println(str3);
        System.out.println(str3.trim());

        System.out.println("------------------");
        String str4 = "hello-java-world";
        String[] ss = str4.split("-");
        for(int i = 0; i <ss.length; i++){
            System.out.println(ss[i]);
        }
        //System.out.println(ss.length);
        System.out.println("------------------");

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串:>");
        String s = sc.next();
        if(s.contains("-")){
            String[] a = s.split("-");
            for(int i = 0; i < a.length; i++){
                System.out.println(a[i]);
            }
        }else {
            System.out.println(s);
        }

        String st = "hello";
        String st2 = st;
        st2 = st2+"world";
        System.out.println(st);
        System.out.println(st2);

    }
}
